<template>
    <view class="testQuestionsInputWrap">
        <view class="itemCom" v-for="item in menuList" :key="item.title" @click="onJump(item.path,item.data)">
            <image :src="`./static/fileIcon/${item.icon}`" style="width: 80rpx;height: 80rpx;margin-right: 32rpx" />
            <view class="flex flex-column">
                <view class="v-center">
                    <view class="title">{{item.title}}</view>
                    <image src="./static/menuIcon/payIcon.svg" style="width: 60rpx;height: 28rpx;margin-left: 20rpx;" v-if="item.isPay"/>
                </view>
                <view class="subTitle">{{ item.desn }}</view>
            </view>
        </view>
    </view>
</template>

<script>
import { onShowTipInfo } from '../utils/PrjUtils';
import { getSubjectStatus } from './services/myQuestionBankService';


export default {
    data() {
        return {
            pInfo:{},
            menuList: [
                {
                    icon: "dg.svg",
                    title: "单题录入",
                    desn: "手动按照单独试题进行录入",
                    path:"singleQuestionPage",
                },
                {
                    icon: "pl.svg",
                    title: "批量录入",
                    desn: "手动批量录入试题",
                    path:"batchEnterQuestion"
                },
                {
                    icon: "excel.svg",
                    title: "Excel导入",
                    desn: "下载Excel导入模板，按照下载模版录入试题并上传",
                    path:"importPage",
                    data:{type:"excel"},
                },
                {
                    icon: "word.svg",
                    title: "Word导入",
                    desn: "下载Word导入模板，按照下载模版录入试题并上传",
                    path:"importPage",
                    data:{type:"word"},
                },
                {
                    icon: "ai.svg",
                    title: "AI智能生成",
                    desn: "上传标准和教材，Ai自动生成章节及试题内容",
                    path:"aiQuestionPage",
                    isPay:true
                },
                {
                    icon: "rg.svg",
                    title: "人工导题",
                    desn: "上传题库文档，客服人员进行试题导入",
                    path:"artificialGuidedQuestions",
                    isPay:true
                }
            ]
        }
    },
    onLoad(option ) {
        let info = JSON.parse(decodeURIComponent(option.info)) || {}
        this.pInfo = info
    },
    onShow() {
       if(this.pInfo.subjectUuid){
            getSubjectStatus({subjectUuid: this.pInfo.subjectUuid}).then(res => {
               this.pInfo={...this.pInfo,doing:res}
            })
       }
    },
    watch: {},
    computed: {},

    methods: {
        onJump(path,data={}){
            if(onShowTipInfo(this.pInfo.doing)){
                //是ai的并且正在生成
                if(this.pInfo.doing=="2"&&path=="aiQuestionPage"){
                    this.onEndJump(path,data={})
                }
                //是人工并且正在生成
                else if(this.pInfo.doing=="1"&&path=="artificialGuidedQuestions"){
                    this.onEndJump(path,data={})
                }
            }   
            else{
               this.onEndJump(path,data)
            }
            // console.log(`/myQuestionBank/${path}?info=${encodeURIComponent(JSON.stringify({...this.pInfo}))}`,"---path")
            
        },
        onEndJump(path,data={}){
            uni.navigateTo({
                     url: `/myQuestionBank/${path}?info=${encodeURIComponent(JSON.stringify({...this.pInfo,...data}))}`
            })
        }
    }
}
</script>

<style lang="scss" scoped>
.testQuestionsInputWrap {
    height: 100vh;
    box-sizing: border-box;
    background-color: #fff;
    padding:0 40rpx;

    .itemCom {
        padding: 40rpx 0 24rpx 0;
        border-bottom: 1rpx solid #F2F2F2;
        display: flex;
        align-items: center;
        .title {
            font-size: 32rpx;
        }

        .subTitle {
            font-size: 24rpx;
            color: #999;
            margin-top: 6rpx;
        }
    }

}
</style>